    <div class="head"><h5 class="iList">Content Type</h5></div>
     <form action="<?php echo url_for('content_types/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" id="valid" class="mainForm" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
     	<div class="rowElem noborder">
     	<label for="name">Name:</label>
     		<div class="formRight"><input type="text" name="content_type[name]" value="<?php echo $form->getObject()->getName()?>"  class="validate[required]"  id="content_type_name"/></div>
     		<div class="fix"></div>
     	</div>
     	<div class="fix"></div>
        <input type="button" value="Save" class="greyishBtn submitForm" id="save" />
        <div class="fix"></div>
     </form>
     
     
<script type="text/javascript">

$("#save").click(function (event){
    submitForm();
})

$("form#valid").submit(function (event){
    event.preventDefault();
    submitForm();
})

function submitForm(){
    var str=$('form#valid').serialize();

    $.ajax({type: 'POST', url:' <?php echo url_for('content_types/'.($form->getObject()->isNew() ? 'create' :'update').
    (!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : ''))?>', script:true, cache:false, data:  str, 
    beforeSend: function(){
        if ($("#name").attr("value") == "") return false; },
            success: function(data) {
                 $('#content_type_container_div').html(data);
                 $('#content_type_name').attr('value',"");
             } });
}

</script>     
